<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理员管理-有点</title>
<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/resource/css.css">
<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/resource/pageGroup.css">

<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/themes/icon.css">
	<script type="text/javascript" src="<?php echo Url::base(); ?>/jquery.min.js"></script>
	<script type="text/javascript" src="<?php echo Url::base(); ?>/jquery.easyui.min.js"></script>



<!-- <script type="text/javascript" src="js/page.js" ></script> -->
</head>
<div style="margin:20px 0;"></div>
<?php  print_r($data);?>
	<table class="easyui-datagrid" title="DataGrid with Toolbar" style="width:900px;height:250px"
			data-options="onDblClickRow:function(index,row){
			window.open ('<?php echo Url::base(); ?>index.php/storem/detail?id='+row.id,'newwindow','height=800,width=900,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') 

		},url:'<?php echo Url::base(); ?>index.php/storem/getData',method:'get',pagination:true,toolbar:toolbar">
		<thead>
			<tr>
				<th data-options="field:'id',width:80,checkbox:true">Item ID</th>
				<th data-options="field:'provinceshow',width:100">省份</th>
				<th data-options="field:'cityshow',width:100">县</th>
				<th data-options="field:'address',width:180,align:'right'">地址</th>

						<th data-options="field:'longitude',width:80">经度</th>
				<th data-options="field:'latitude',width:100">纬度</th>
				<th data-options="field:'isget',width:100,formatter: function(value,row,index){
				
				if (row.isget == 1){
					return '支持';
				} else {
					return '不支持';
				}
			}">是否支持自提</th>
				<th data-options="field:'isstore',width:180,align:'right',formatter: function(value,row,index){
				
				if (row.isstore == 1){
					return '支持';
				} else {
					return '不支持';
				}
			}">是否支持门店配送</th>
			</tr>
		</thead>

	</table>


<form id="form" name="form" method="post" action="<?php echo Url::base(); ?>index.php/productskum/addProductSku">
	<input type="button" id="config" value="添加配置" onclick="get(this)">
	<?php
		foreach($data['list'] as $key=>$value){
	?>

	<div>
		省份:<?php  echo $value['province'];?>   县:<?php  echo $value['province'];?>  库存:
		<input type="text" name="number[]" value="<?php  echo $value['number'];?>"><input type="hidden" value="<?php  echo $value['storeId'];?>" name="storeId[]">
		<input type="button" value="删除" onclick="del(this)"></div>
			<?php
		}
	?>
	<input type="submit" value="提交" >
	<input type="hidden" name="specificationId" value="<?php echo $data['id'][0] ?>"/>
	<input type="hidden" name="productId" value="<?php echo $data['productId']; ?>"/>

</form>
	<script type="text/javascript">
		function del(obj){
			$(obj).parent().remove()
		}
		function get(obj){
			var rows = $('.easyui-datagrid').datagrid('getChecked');
			console.log(rows)
			if(rows.length ==0){
				alert("请选择门店配送地址")
			}else{
				if($('input[name="storeId[]"]').length == 0){
					for(var i = 0;i<rows.length;i++) {
							$("#config").after('<div>省份:'+rows[i].cityshow+'   县:'+rows[i].provinceshow+'  库存:<input type="text" name="number[]"><input type="hidden" value="'+rows[i].id+'"name="storeId[]"><input type="button" value="删除" onclick="del(this)"></div> ')

					}
				}else{
					$('input[name="storeId[]"]').each(function(key,value){
						var flag = true;
						for(var i = 0;i<rows.length;i++) {
							if($(value).val()==rows[i].id){
								flag=false;
								break;
							}

						}
						if(flag){
							$("#config").after('<div>省份:'+rows[i].cityshow+'   县:'+rows[i].provinceshow+'  库存:<input type="text" name="number[]"><input type="hidden" value="'+rows[i].id+'"name="storeId[]"><input type="button" value="删除" onclick="del(this)"></div> ')

						}
					})
				}


			}

		}
		$(function(){

			$('#dlg').dialog('close')
		})
		var toolbar = [{
			text:'Add',
			iconCls:'icon-add',
			handler:function(){window.location.href='<?php echo Url::base(); ?>index.php/storem/add'}
		}];
	</script>
</body></html>